#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
	int num1 = 0, num2 = 0;
	int gcd = 0;
	scanf("%d %d", &num1, &num2);
	int max = num1 > num2 ? num1 : num2;
	int min = num1 < num2 ? num1 : num2;
	while (max%min!=0)
	{
		int temp = max % min;
		max = min;
		min = temp;
	}
	gcd = min;
	printf("%d\n", gcd);
	return 0;
}